﻿<Window x:Class="ImoutoDesktop.Windows.BalloonWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ImoutoDesktop="clr-namespace:ImoutoDesktop"
    xmlns:ImoutoDesktop_Controls="clr-namespace:ImoutoDesktop.Controls"
    Width="{Binding ElementName=baseImage, Path=ActualWidth}" Height="{Binding ElementName=baseImage, Path=ActualHeight}"
    Topmost="{Binding Path=Topmost, Source={x:Static ImoutoDesktop:Settings.Default}}"
    DataContext="{Binding RelativeSource={RelativeSource self}, Path=Balloon}"
    AllowsTransparency="True" Background="Transparent" WindowStyle="None" ShowInTaskbar="False" ShowActivated="False"
    PreviewMouseLeftButtonDown="BalloonWindow_MouseLeftButtonDown" PreviewMouseLeftButtonUp="BalloonWindow_MouseLeftButtonUp"
    MouseMove="BalloonWindow_MouseMove" Activated="BalloonWindow_Activated">
    <Window.Resources>
        <Style TargetType="{x:Type RepeatButton}">
            <Style.Setters>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type RepeatButton}">
                            <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style.Setters>
        </Style>
        <Style TargetType="{x:Type TextBox}">
            <Style.Setters>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TextBox}">
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True">
                                <ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style.Setters>
        </Style>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </Window.Resources>
    <Grid>
        <Image x:Name="baseImage" Stretch="None" Source="{Binding Path=Image}" />
        <Grid Margin="15">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ImoutoDesktop_Controls:TextViewer x:Name="textViewer" Grid.Column="0" Grid.Row="0" />
            <RepeatButton Grid.Column="1" Grid.Row="0" Margin="0,0,-10,0" CommandTarget="{Binding ElementName=textViewer}" Command="ScrollBar.LineUpCommand"
                      VerticalAlignment="Top" Visibility="{Binding ElementName=textViewer, Path=CanScrollUp, Converter={StaticResource BooleanToVisibilityConverter}}">
                <Image Stretch="None" Source="{Binding Path=ArrowUpImage}" />
            </RepeatButton>
            <RepeatButton Grid.Column="1" Grid.Row="0" Margin="0,0,-10,0" CommandTarget="{Binding ElementName=textViewer}" Command="ScrollBar.LineDownCommand"
                      VerticalAlignment="Bottom" Visibility="{Binding ElementName=textViewer, Path=CanScrollDown, Converter={StaticResource BooleanToVisibilityConverter}}">
                <Image Stretch="None" Source="{Binding Path=ArrowDownImage}" />
            </RepeatButton>
            <TextBox x:Name="textBox" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,2,0,0" BorderBrush="#BBBBBB" PreviewKeyDown="TextBox_PreviewKeyDown" KeyDown="TextBox_KeyDown" />
        </Grid>
    </Grid>
</Window>
